<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 定义局部组件
    const SubTitle = {
      template:`
        <div>
          我是一个局部组件 
          {{ title }} 
          {{ title2 }}
          {{ title3 }}
        </div>
      `,
      props:['title','title2'], // properties  
      data(){
        return {
          title3:'自己内部的数据'
        }
      } 
    }
    // 定义全局组件
    const Home = {
      template:`
        <div>
          <h3>home</h3>
          <sub-title title="我是home传的标题" :title2="msg"></sub-title>
        </div>
        
      `,
      data(){
        return {
          msg:'我是home组件的数据'
        }
      },
      methods:{
        changeMsg(){
          this.msg = "数据改变了"
        }
      },
      components:{
        SubTitle
      }
    }
    Vue.component("Home", Home)
    const vm = new Vue({
      el:"#app"
    })
  </script>
</body>
</html>
